package zheezes.protocol.impl.gbw.bean;

import zheezes.protocol.impl.gbw.format.DataForm32;
import zheezes.util.ByteUtil;

// TODO to complete the multi-rates
public class DailyFrozenData {
	private short seq;
	private byte days;
	private byte rates = 0;
	private DataForm32 value = new DataForm32();

	public int sizeof() {
		return 2 + 1 + 1 + value.sizeof();
	}

	public int getBytes(byte[] buf, int offset) {
		int idx = offset;
		ByteUtil.stoc(buf, idx, seq);
		idx += 2;
		buf[idx++] = days;
		buf[idx++] = rates;
		idx += value.getBytes(buf, idx);

		return idx - offset;
	}

	public int setBytes(byte[] buf, int offset) {
		int idx = offset;
		seq = ByteUtil.ctos(buf, idx);
		idx += 2;
		days = buf[idx++];
		rates = buf[idx++];
		idx += value.setBytes(buf, idx);
		
		return idx - offset;
	}

	public short getSeq() {
		return seq;
	}

	public void setSeq(short seq) {
		this.seq = seq;
	}

	public byte getDays() {
		return days;
	}

	public void setDays(byte days) {
		this.days = days;
	}

	public byte getRates() {
		return rates;
	}

	public void setRates(byte rates) {
		this.rates = rates;
	}

	public DataForm32 getValue() {
		return value;
	}

	public void setValue(DataForm32 value) {
		this.value = value;
	}
}
